<template>
    <view>
        <view class="tips">1、请获取欧易的相关Key；用于同步持仓和交易数据</view>
        <view class="tips">2、输入或者复制粘贴你的相关Key</view>
        <view class="labels">
            <view class="labname">API Key</view>
            <input class="yzms" v-model="apiKey" placeholder-style="color:#ADB0BB" type="text" placeholder="请输入API Key" />
        </view>
        <view class="labels">
            <view class="labname">Secret Key</view>
            <input class="yzms" v-model="secretKey" placeholder-style="color:#ADB0BB" type="text" placeholder="请输入Secret Key" />
        </view>
		<view class="labels">
		    <view class="labname">passphrase</view>
		    <input class="yzms" v-model="passphrase" placeholder-style="color:#ADB0BB" type="text" placeholder="请输入passphrase" />
		</view>
        <button class="importfns" @click="importapifn">导入</button>
    </view>
</template>

<script>
    let uinfo;
    import request from "../../untils/request.js"
    export default {
        data() {
            return {
                apiKey: '',
                secretKey: '',
            }
        },
        onLoad() {
            uinfo = uni.getStorageSync('userInfo');
        },
        onNavigationBarButtonTap: function(e) {
            uni.navigateTo({
                url:'../course/course',
            })
        },
        methods: {
            importapifn() {
                uni.showLoading({
                    mask:true
                });
                request.postMember('/user/exchange/okex/okexBinding', {
                    accountId: '', //账户ID,当新增绑定时无需传入该参数 ,
                    accountTransType: '0', //账户类型:0:跟单者1.发单者 ,
                    apiKey: this.apiKey,
                    bizType: '1', //账户类型: 0现货,1合约 ,
                    coins: '', //支持的币种,多币种用 , 分割 ,
                    secretKey: this.secretKey,
					passphrase: this.passphrase,
                    userId: uinfo.userId
                }).then(res => {
                    console.log(res)
                    if (res.code == '200') {
                        this.apiKey = '';
                        this.secretKey = '';
                        uni.hideLoading();
                        uni.showToast({
                            icon: "none",
                            title: '导入成功',
                        });
                        uni.switchTab({
                            url: '/pages/mine/mine',
                        });
                    } else {
                        uni.hideLoading();
                        uni.showToast({
                            icon: "none",
                            title: res.message,
                        });
                    }
                })
            }

        }
    }
</script>

<style>
    .tips {
        font-size: 14px;
        font-family: Source Han Sans CN;
        font-weight: 400;
        color: #ADB0BB;
        margin: 0 16px 0;
        padding: 0 0 10px 0;
    }

    .labels {
        margin: 0 30rpx;
        border-bottom: 1px solid #EBEBEB;
        height: 120rpx;
    }

    .labels .labname {
        font-size: 32rpx;
        font-family: Source Han Sans CN;
        font-weight: 600;
        margin: 16px 0 10px 0;
        color: #333333;
    }

    .labels input {
        font-size: 14px;
        font-family: Source Han Sans CN;
        font-weight: 400;
        line-height: 24px;
    }

    .importfns {
        width: 260px;
        height: 38px;
        background: #7F6AC3;
        border-radius: 19px;
        font-size: 14px;
        font-family: Source Han Sans CN;
        font-weight: 400;
        color: #FFFFFF;
        margin: 110px auto 0;
    }
</style>
